﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.API.Application.Command.BasicTraceability;
using Traceability.App.API.DTOs;
using Traceability.App.Domain.Traceability;
using Traceability.App.ErrorCode;

namespace Traceability.App.API.Controllers
{
    /// <summary>
    /// 溯源基本信息控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BasicTraceabilityController : ControllerBase
    {
        private readonly IMediator mediator;

        public BasicTraceabilityController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加溯源基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> CreateBasicTraceability(CreateBasicTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取商品信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<GoodModel>>> GetGood([FromQuery]GetGoodCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取溯源基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIPaging<BasicTraceabilityDTO>> GetBasicTraceability([FromQuery]GetBasicTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 批量删除溯源基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<int>> DelBasicTraceability([FromQuery]DelBasicTracebilityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改溯源基本信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdBasicTraceability(UpdBasicTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据批次获取溯源基本信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<BasicTraceabilityModel>>> GetIdBasicTraceability([FromQuery]GetIdBasicTraceabilityCommand request)
        {
            return mediator.Send(request);
        }
    }
}
